<template>
	<view class="box" v-if="pageshow">
		<view class="task">
			<view class="titletext bold hei_text">{{dataAll.clrw.title}}</view>
			<view class="margin_top">
				<u-parse :content="dataAll.clrw.content"></u-parse>
			</view>
			<view class="right"  v-if="Number(dataAll.clrw.end_time) *1000 > Number(new Date())">
				截至时间:
				<text class="time" style="color: #28C445;">{{DifferenceTimer(dataAll.clrw.end_time*1000,Number(new Date()))}}天</text>
			</view>
			<view class="right" v-else>已过期</view>
			<view class="btn" v-if="!dataAll.clrwrecord" @click="lingqu">领取任务</view>
			<template v-else="dataAll.clrwrecord">
				<view class="btn" v-if="dataAll.clrwrecord.status==0" @click="gotoUpTask">上传任务</view>
				<view class="btn hui" v-if="dataAll.clrwrecord.status==10">待审核</view>
				<view class="btn green" v-if="dataAll.clrwrecord.status==20">审核成功</view>
				<view class="btn red " v-if="dataAll.clrwrecord.status==30" @click="gotoUpTask">审核不通过重新提交</view>
				<view class="btn hui" v-if="dataAll.clrwrecord.status==40">已结束</view>
			</template>
		</view>
	</view>
</template>

<script>
	import httpRequest from '@/commonFun/httpRequest.js'
	export default {
		data() {
			return {
				pageshow:false,
				dataAll: {},
				id: '',
			}
		},
		onLoad(i) {
			this.id = i.id;
			
		},
		onShow() {
			this.getdata();
		},
		methods: {
			DifferenceTimer(now,before){
				let num_day = (Number(now) - Number(before)) / (1000*60*60*24);
				return num_day.toFixed(0)
			},
			djsonChange(e){
				this.dataAll.timeData = e
			},
			getdata(id){
				let _this = this;
				httpRequest.request('/customapi/user/clrwDetail','POST',{
					id:this.id,
				}).then(res => {
					this.pageshow = true
					if(res.code == 1){
						this.$set(res.data,"timeData",{})
						_this.dataAll = res.data;
					}
				})
			},
			gotoUpTask(){
				uni.navigateTo({
					url:"upTask?id=" + this.id
				})
			},
			lingqu(){
				let _this = this;
				httpRequest.request('/customapi/user/lqClrw', 'POST', {
					id:_this.id
				}).then(res => {
					httpRequest.toast(res.msg);
					if(res.code==1){
						this.getdata();
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.dis{
		background-color: #999999 !important;
	}
.box{
	height: 100vh;
	background-color: #ffffff;
	.task{
		padding: 74rpx 51rpx  0 51rpx;
		overflow: hidden;
		.taskDetail{
			margin-bottom: 20rpx;
		}
		.right{
			text-align: right;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 800;
			color: #000000;
			margin-top: 60rpx;
		}
		.btn{
			background: #F5AC4F;
			border-radius: 20rpx;
			text-align: center;
			color: #ffffff;
			padding: 34rpx;
			position: absolute;
			bottom: 60rpx;
			width: 78vw;
			// margin-top: 50vh;
			// margin-top: 340px;
		}
		.red{
			background-color: #ff0000;
		}
		.hui{
			background-color: #999;
		}
		.green{
			background-color: #28C445;
		}
	}
}
</style>
